package com.group4.xiao_ge_lai_yi_zhu.controller.change_prize_controller;

import com.group4.xiao_ge_lai_yi_zhu.dao.UserDAO;


import java.util.*;

public class TalkAboutIt {
    UserDAO userDAO = new UserDAO();
    private Scanner sc = new Scanner(System.in);

    public void talkAbout() {
        HashMap<String, String> map = userDAO.findLottery();
        //奖金号码
        String[] ss = JiShiQi.nums;

        //中奖方法
        boolean zzyf = false;
        lo:
        while (true) {
            System.out.println("请输入你的彩票序号,想要退出请输入退出");
            String sid = sc.next();
            System.out.println("当前开奖号码为");
            for (int i = 0; i < ss.length; i++) {
                System.out.print(ss[i]+" ");
            }
            System.out.println();
            if (sid.equals("退出")) {
                break;
            }
            //获取用户数据
            Set<String> keySet = map.keySet();
            int redCount = 0;
            for (String str : keySet) {
                if (str.equals(sid)) {
                    zzyf = true;
                    String value = map.get(str);
                    String[] s1 = value.split(" ");
                    //当前号码
                    System.out.println("您的号码为:");
                    for (int i = 0; i < s1.length; i++) {
                        System.out.print(s1[i] + " ");
                    }
                    System.out.println();
                    //判断流程
                    for (int ii = 0; ii < ss.length - 1; ii++) {
                        for (int i1 = 0; i1 < s1.length - 1; i1++) {
                            if (ss[ii].equals(s1[i1])) {
                                redCount++;
                            }
                        }
                    }
                    //蓝色
                    boolean blue = false;
                    if (s1[7].equals(ss[7])) {
                        blue = true;
                    }
                    if (redCount == 6 && blue) {
                        System.out.println("一等奖");
                        System.out.println();
                    } else if (redCount == 6 && blue) {
                        System.out.println("二等奖");
                        System.out.println();
                    } else if (redCount == 5 && blue) {
                        System.out.println("三等奖");
                        System.out.println();
                    } else if ((redCount == 5 && blue)
                            || (redCount == 4 && blue)) {
                        System.out.println("四等奖");
                        System.out.println();
                    } else if ((redCount == 4 && blue)
                            || (redCount == 3 && blue)) {
                        System.out.println("五等奖");
                        System.out.println();
                    } else if ((redCount == 2 && blue)
                            || (redCount == 1 && blue)
                            || (redCount == 0 && blue)) {
                        System.out.println("六等奖");
                        System.out.println();
                    } else {
                        System.out.println("感谢您的参与");
                        System.out.println();
                    }
                    break;
                }
            }
        if (!zzyf) {
            System.out.println("无此彩票序号,请重新输入");
        }
        }
    }
}